package com.taoyibao.hongcanting.ui.home.activity;

import android.content.Context;
import android.content.Intent;

import com.taoyibao.hongcanting.base.activity.BaseActivityPresenter;
import com.taoyibao.hongcanting.constant.CodeConstant;
import com.taoyibao.hongcanting.model.DishModel;
import com.taoyibao.hongcanting.ui.home.delegate.DishDetailsDelegate;
import com.taoyibao.hongcanting.utils.LogUtils;

/**
 * @author TangAnna
 * @description: 菜品详情
 * @date :${DATA} 15:21
 */
public class DishDetailsActivity extends BaseActivityPresenter<DishDetailsDelegate> {

    private DishModel mDishModel;

    @Override
    protected Class<DishDetailsDelegate> getDelegateClass() {
        return DishDetailsDelegate.class;
    }

    /**
     * @param c
     * @param type 菜品分类
     * @param id   菜品ID
     */
    public static void open(Context c, String type, String id) {
        Intent intent = new Intent(c, DishDetailsActivity.class);
        intent.putExtra(CodeConstant.DISH_TYPE, type);
        intent.putExtra(CodeConstant.DISH_ID, id);
        c.startActivity(intent);
    }

    /**
     * @param context
     * @param dishModel 当前菜品的数据
     */
    public static void open(Context context, DishModel dishModel) {
        Intent intent = new Intent(context, DishDetailsActivity.class);
        intent.putExtra(CodeConstant.MODEL, dishModel);
        context.startActivity(intent);
    }

    @Override
    protected void bindEvenListener() {
        super.bindEvenListener();
        mDishModel = (DishModel) getIntent().getSerializableExtra(CodeConstant.MODEL);
        LogUtils.dNormal("菜品数据", mDishModel.toString());
        viewDelegate.setDishModel(mDishModel);

    }
}
